//
//  YJDoctordetailInfoView.m
//  QuickCure1
//
//  Created by 陶永久 on 2016/10/31.
//  Copyright © 2016年 maoge. All rights reserved.
//

#import "YJDoctordetailInfoView.h"
#import "YJDoctorsIfonModel.h"

@interface YJDoctordetailInfoView()

@property (weak, nonatomic) IBOutlet UIImageView *doctor_portrait;

@property (weak, nonatomic) IBOutlet UILabel *doctor_name;
@property (weak, nonatomic) IBOutlet UILabel *doctor_title_name;
@property (weak, nonatomic) IBOutlet UILabel *doctor_hospital_name;
@property (weak, nonatomic) IBOutlet UILabel *operation_count;
@property (weak, nonatomic) IBOutlet UILabel *flower;
@property (weak, nonatomic) IBOutlet UILabel *banner;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *constraintCenterX;
@property (weak, nonatomic) IBOutlet UIView *lineView;

@property (weak, nonatomic) IBOutlet UIButton *fristButton;

@end




@implementation YJDoctordetailInfoView


+ (instancetype)doctordetailInfoView
{
    return [[[NSBundle mainBundle] loadNibNamed:@"YJDoctordetailInfoView" owner:nil options:nil] lastObject];
}


/**
 点击button的监听事件
 */
- (IBAction)clickbutton:(UIButton *)sender {
    
    NSAssert(_clickButtonBlock != nil, @"clickButtonBlock不能为空!");
    
    if (sender.tag == 1)
    {
        [UIView animateWithDuration:0.3 animations:^{
            
            self.lineView.transform = CGAffineTransformIdentity;

        }];
        
    }else if (sender.tag == 2)
    {
        [UIView animateWithDuration:0.3 animations:^{
            self.lineView.transform = CGAffineTransformMakeTranslation(sender.frame.size.width + 2, 0);
        }];
        
    }
    
    _clickButtonBlock(sender.tag);
}

- (void)setOffsetX:(CGFloat)offsetX
{
    _offsetX = offsetX;
    
    NSInteger index = offsetX / self.frame.size.width + 0.5;

    [UIView animateWithDuration:0.3 animations:^{
         self.lineView.transform = CGAffineTransformMakeTranslation(_fristButton.frame.size.width * index + 2, 0);
    }];
    
   
    
    
}

- (void)setModel:(YJDoctorsIfonModel *)model
{
    _model = model;
    
    self.doctor_name.text = model.doctor_name;
    
    self.doctor_title_name.text = model.doctor_title_name;
    
    self.doctor_hospital_name.text = [@"医院:" stringByAppendingString:model.doctor_hospital_name];
    
    self.operation_count.text = [@"预约量:" stringByAppendingString:model.operation_count.description];
    
    self.flower.text = [@"鲜花数:" stringByAppendingString:model.flower.description];
    
    self.banner.text = [@"锦旗数:" stringByAppendingString:model.banner.description];
    
    [self.doctor_portrait sd_setImageWithURL:[NSURL URLWithString:model.doctor_portrait]];
    
    self.doctor_portrait.layer.cornerRadius = 25;
    
    self.doctor_portrait.layer.masksToBounds = YES;
    
}
@end
